﻿using System.Web.Mvc;
using NOSDC.Models;
using NOSDC.Pocos;
using NOSDC.Services;

namespace NOSDC.Controllers
{
    public class JobsController : Controller
    {
        private readonly IJobService _jobService;
       
        public JobsController()
            : this(new JobService()) { }

        public JobsController(IJobService jobService)
        {
            _jobService = jobService;
        }

        [Authorize(Roles = "Member")]
        public ActionResult Index()
        {
            var model = _jobService.GetActiveJobs();
            return View(model);
        }

        [Authorize(Roles = "Member")]
        public ActionResult Details(int? JobID, string Title)
        {
            var model = _jobService.GetJobById(JobID ?? 0);
            return View(model ?? new Job());
        }

        public ActionResult RecentJobs()
        {
            var model = new RecentJobs { Jobs = _jobService.GetRecentJobs() };

            return PartialView("Jobs/_RecentJobs", model);
        }
    }
}
